package com.example.dao;

import com.example.entity.Ban;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
//@Repository
public interface BanDao {


    @Select("SELECT DISTINCT ban_number from ban")
    public List<Ban> getAllBanNumber();

    /**
     * 分页查询
     * @param currentPage  当前页
     * @param pageSize     当前页条数
     * @return
     */
    @Select("select * from ban limit #{currentPage}, #{pageSize}")
    public List<Ban> getPage(@Param("currentPage") int currentPage, @Param("pageSize")int pageSize);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*) from ban")
    public int getTotalCount();


    @Insert("insert into ban(ban_number,ban_name,stu_number,major,ban_head) " +
            "values(#{banNumber},#{banName},#{stuNumber},#{major},#{banHead})")
    public int add(Ban ban);

    @Delete("delete from ban where id=#{id}")
    public Boolean deleteById(@Param("id") Integer id);

    @Update("update ban set ban_number=#{banNumber},ban_name=#{banName},stu_number=#{stuNumber}" +
            ",major=#{major},ban_head=#{banHead} where id=#{id}")
    public int update(Ban ban) ;
}
